Document return values of the various read-* functions
authorEli Zaretskii <eliz@gnu.org>
Sun, 9 Mar 2025 13:02:39 +0000 (15:02 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sun, 9 Mar 2025 13:02:39 +0000 (15:02 +0200)
* lisp/textmodes/string-edit.el (read-string-from-buffer):
* lisp/simple.el (read-from-kill-ring, read-shell-command)
(read-signal-name):
* lisp/replace.el (read-regexp-case-fold-search):
* lisp/auth-source.el (read-passwd):
* lisp/subr.el (read-key, read-number):
* lisp/minibuffer.el (read-file-name, read-no-blanks-input):
* lisp/international/mule-cmds.el (read-multilingual-string):
* lisp/language/japan-util.el (read-hiragana-string):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-mode, read-file-local-variable-value):
* lisp/faces.el (read-face-font, read-face-name):
* lisp/simple.el (read-extended-command):
* lisp/env.el (read-envvar-name):
* lisp/files.el (read-directory-name):
* lisp/faces.el (read-color):
* lisp/international/mule-diag.el (read-charset):
* lisp/emacs-lisp/map-ynp.el (read-answer):
* src/coding.c (Fread_coding_system)
(Fread_non_nil_coding_system):
* src/minibuf.c (Fread_command, Fread_from_minibuffer):
* src/lread.c (Fread_char, Fread_char_exclusive, Fread_event): Doc
fixes.

17 files changed:
lisp/auth-source.el
lisp/emacs-lisp/map-ynp.el
lisp/env.el
lisp/faces.el
lisp/files-x.el
lisp/files.el
lisp/international/mule-cmds.el
lisp/international/mule-diag.el
lisp/language/japan-util.el
lisp/minibuffer.el
lisp/replace.el
lisp/simple.el
lisp/subr.el
lisp/textmodes/string-edit.el
src/coding.c
src/lread.c
src/minibuf.c

index d22747493b23ab2e1c08368a2dcb7696db0e8981..c72cb24cf743e0f8d18f2395719ab30f51131535 100644 (file)
@@ -2551,7 +2551,7 @@ Adapt also mode line."
 
 ;;;###autoload
 (defun read-passwd (prompt &optional confirm default)
-  "Read a password, prompting with PROMPT, and return it.
+  "Read a password, prompting with PROMPT, and return password as a string.
 If optional CONFIRM is non-nil, read the password twice to make sure.
 Optional DEFAULT is a default password to use instead of empty input.
 
index 2d24f7839583e3b2731261e40e87b365a8181f5b..5b9ffe3a03db5b76dc72d73db559aed58999b7ba 100644 (file)
@@ -312,6 +312,7 @@ variable."
 (defun read-answer (question answers)
   "Read an answer either as a complete word or its character abbreviation.
 Ask user a question and accept an answer from the list of possible answers.
+Return the long answer even when accepting short ones.
 
 QUESTION should end in a space; this function adds a list of answers to it.
 
@@ -335,8 +336,6 @@ Example:
 
 When `read-answer-short' is non-nil, accept short answers.
 
-Return a long answer even in case of accepting short ones.
-
 When `use-dialog-box' is t, pop up a dialog window to get user input."
   (let* ((short (if (eq read-answer-short 'auto)
                     (or use-short-answers
index 288f7e224d71a6c40aa65f38218dee837cf53d53..9e8b7f53a11b3621718d0f496a20d459c4df64df 100644 (file)
@@ -38,7 +38,7 @@
 (defvar read-envvar-name-history nil)
 
 (defun read-envvar-name (prompt &optional mustmatch)
-  "Read environment variable name, prompting with PROMPT.
+  "Read and return an environment variable name string, prompting with PROMPT.
 Optional second arg MUSTMATCH, if non-nil, means require existing envvar name.
 If it is also not t, RET does not exit if it does non-null completion."
   (completing-read prompt
index 01800c4c1055dce88af027d55c430acbce1844cc..bbd6bf06d03480704f9f6f2ecfe30f663e5a78bf 100644 (file)
@@ -1102,7 +1102,7 @@ of the default face.  Value is FACE."
   "Text string to display as the sample text for `read-face-name'.")
 
 (defun read-face-name (prompt &optional default multiple)
-  "Read one or more face names, prompting with PROMPT.
+  "Read and return one or more face names, strings, prompting with PROMPT.
 PROMPT should not end in a space or a colon.
 
 If DEFAULT is non-nil, it should be a face (a symbol) or a face
@@ -1382,7 +1382,7 @@ of a global face.  Value is the new attribute value."
                  (pattern &optional face frame maximum width))
 
 (defun read-face-font (face &optional frame)
-  "Read the name of a font for FACE on FRAME.
+  "Read and return the string name of the font for FACE on FRAME.
 If optional argument FRAME is nil or omitted, use the selected frame."
   (let ((completion-ignore-case t))
     (completing-read (format-message
@@ -1990,7 +1990,7 @@ If omitted or nil, that stands for the selected frame's display."
 
 (defun read-color (&optional prompt convert-to-RGB allow-empty-name msg
                             foreground face)
-  "Read a color name or RGB triplet.
+  "Read a color name or RGB triplet, return a string, the color name or RGB.
 Completion is available for color names, but not for RGB triplets.
 
 RGB triplets have the form \"#RRGGBB\".  Each of the R, G, and B
index cdc38508c5ac9b016bf4e4305542dd70b67bb7d5..82b69de7c17b21fc0bf588c66427f2a5e068781f 100644 (file)
@@ -38,7 +38,9 @@
 ;;; Commands to add/delete file-local/directory-local variables.
 
 (defun read-file-local-variable (prompt)
-  "Read file-local variable using PROMPT and completion.
+  "Read the name of a file-local variable using PROMPT and completion.
+Return the symbol of the variable, or nil if the user entered empty or
+null name.
 Intended to be used in the `interactive' spec of
 `add-file-local-variable', `delete-file-local-variable',
 `add-dir-local-variable', `delete-dir-local-variable'."
@@ -57,7 +59,7 @@ Intended to be used in the `interactive' spec of
     (and (stringp variable) (intern variable))))
 
 (defun read-file-local-variable-value (variable)
-  "Read value of file-local VARIABLE using completion.
+  "Read and return the value of a file-local VARIABLE using completion.
 Intended to be used in the `interactive' spec of
 `add-file-local-variable' and `add-dir-local-variable'."
   (cond
@@ -90,7 +92,9 @@ Intended to be used in the `interactive' spec of
                            default)))))
 
 (defun read-file-local-variable-mode ()
-  "Read per-directory file-local variable's mode using completion.
+  "Read the name of a per-directory file-local variable's mode using completion.
+Return the symbol of the variable, or nil if the user entered empty or
+null name.
 Intended to be used in the `interactive' spec of
 `add-dir-local-variable', `delete-dir-local-variable'."
   (let* ((default (and (symbolp major-mode) (symbol-name major-mode)))
index 380721f1fe2c510eea51b76f172a510241ac6234..007fd23a5f5dc621b71adf2c7ed18c9100e3efd9 100644 (file)
@@ -885,6 +885,7 @@ Default name to DEFAULT-DIRNAME if user exits with the same
 non-empty string that was inserted by this function.
  (If DEFAULT-DIRNAME is omitted, DIR combined with INITIAL is used,
   or just DIR if INITIAL is nil.)
+Return the directory as a string.
 If the user exits with an empty minibuffer, this function returns
 an empty string.  (This can happen only if the user erased the
 pre-inserted contents or if `insert-default-directory' is nil.)
index 4d153ea91dbf417104bfa8af4ae4f16962bf6294..24ae65c1145b302c9c3adc61568c6e57a91d32a2 100644 (file)
@@ -1676,6 +1676,7 @@ This is a subroutine for `describe-input-method'."
 
 (defun read-multilingual-string (prompt &optional initial-input input-method)
   "Read a multilingual string from minibuffer, prompting with string PROMPT.
+Return the string thus read.
 The input method selected last time is activated in minibuffer.
 If optional second argument INITIAL-INPUT is non-nil, insert it in the
 minibuffer initially.
index 03376e876bfdcebab7d0ca3931bb40e9d90f908b..44d20e39507167aa303c5377d4baed7878e9f419 100644 (file)
@@ -206,6 +206,7 @@ Character sets for defining other charsets, or for backward compatibility
 (defun read-charset (prompt &optional default-value initial-input)
   "Read a character set from the minibuffer, prompting with string PROMPT.
 It must be an Emacs character set listed in the variable `charset-list'.
+Return the charset as a symbol.
 
 Optional arguments are DEFAULT-VALUE and INITIAL-INPUT.
 DEFAULT-VALUE, if non-nil, is the default value.
index c61e98c8fca90cffa881da8819296ed93550d516..718c469d5622cff96dd9e40c8954a34bca193b4e 100644 (file)
@@ -317,7 +317,8 @@ Optional argument KATAKANA-ONLY non-nil means to convert only KATAKANA char."
 ;;;###autoload
 (defun read-hiragana-string (prompt &optional initial-input)
   "Read a Hiragana string from the minibuffer, prompting with string PROMPT.
-If non-nil, second arg INITIAL-INPUT is a string to insert before reading."
+If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
+Return the string read from the minibuffer."
   (read-multilingual-string prompt initial-input "japanese-hiragana"))
 
 ;;
index cfce7de8df17b2cb8095897c672eccb628130d99..f0db98cdc1d3eb3eda82794762f262a2f74e5e97 100644 (file)
@@ -3091,7 +3091,7 @@ with `minibuffer-local-must-match-map'."
   "?"   #'self-insert-and-exit)
 
 (defun read-no-blanks-input (prompt &optional initial inherit-input-method)
-  "Read a string from the terminal, not allowing blanks.
+  "Read and return a string from the terminal, not allowing blanks.
 Prompt with PROMPT.  Whitespace terminates the input.  If INITIAL is
 non-nil, it should be a string, which is used as initial input, with
 point positioned at the end, so that SPACE will accept the input.
@@ -3473,7 +3473,8 @@ like the `beginning-of-buffer' command."
      (if (listp default) default (list default)))))
 
 (defun read-file-name (prompt &optional dir default-filename mustmatch initial predicate)
-  "Read file name, prompting with PROMPT and completing in directory DIR.
+  "Read a file name, prompting with PROMPT and completing in directory DIR.
+Retrun the file name as a string.
 The return value is not expanded---you must call `expand-file-name'
 yourself.
 
index e17514215ef6263e154cb39d295835855e680053..beecc78c43730806bfc2603170bf6f56379f631e 100644 (file)
@@ -929,7 +929,7 @@ regexp from the user."
       (or result input))))
 
 (defun read-regexp-case-fold-search (regexp)
-  "Return a value for `case-fold-search' based on REGEXP and current settings.
+  "Return the value for `case-fold-search' based on REGEXP and current settings.
 REGEXP is a string as returned by `read-regexp'."
   (let ((fold (get-text-property 0 'case-fold regexp)))
     (cond
index 152a8c451ac3654a06d120406c09f172fe11e955..e1f6ae8b68332443c6ba0ff6c8918de8660baf55 100644 (file)
@@ -2275,7 +2275,7 @@ This is used by the \\<minibuffer-local-must-match-map>\\[execute-extended-comma
   "Minor mode used for completion in `read-extended-command'.")
 
 (defun read-extended-command (&optional prompt)
-  "Read command name to invoke via `execute-extended-command'.
+  "Read and return name of command to invoke via `execute-extended-command'.
 Use `read-extended-command-predicate' to determine which commands
 to include among completion candidates.
 
@@ -4311,7 +4311,7 @@ after the default value."
   "Keymap used for completing shell commands in minibuffer.")
 
 (defun read-shell-command (prompt &optional initial-contents hist &rest args)
-  "Read a shell command from the minibuffer.
+  "Read a shell command from the minibuffer, and return it as a string.
 The arguments are the same as the ones of `read-from-minibuffer',
 except READ and KEYMAP are missing and HIST defaults
 to `shell-command-history'."
@@ -6431,7 +6431,8 @@ variable to determine how strings should be escaped."
 (defvar read-from-kill-ring-history)
 (defun read-from-kill-ring (prompt)
   "Read a `kill-ring' entry using completion and minibuffer history.
-PROMPT is a string to prompt with."
+PROMPT is a string to prompt with.
+Return the entry as a string."
   ;; `current-kill' updates `kill-ring' with a possible interprogram-paste
   (current-kill 0)
   (let* ((history-add-new-input nil)
@@ -11193,7 +11194,9 @@ killed."
   (string= string ""))
 
 (defun read-signal-name ()
-  "Read a signal number or name."
+  "Read a signal number or name.
+Return the signal number, if the user entered a number, otherwise
+the signal symbol."
   (let ((value
          (completing-read "Signal code or name: "
                           (signal-names)
index 37a3f9efe6b6b4d2f5cbece981d77166f632a500..42706397674a879fe3f56f794dee36945b31343b 100644 (file)
@@ -3309,7 +3309,7 @@ miscellaneous values associated with the process."
 (defvar read-key-delay 0.01) ;Fast enough for 100Hz repeat rate, hopefully.
 
 (defun read-key (&optional prompt disable-fallbacks)
-  "Read a key from the keyboard.
+  "Read a key from the keyboard, return the event thus read.
 Contrary to `read-event' this will not return a raw event but instead will
 obey the input decoding and translations usually done by `read-key-sequence'.
 So escape sequences and keyboard encoding are taken into account.
@@ -3423,7 +3423,7 @@ with Emacs.  Do not call it directly in your own packages."
   "The default history for the `read-number' function.")
 
 (defun read-number (prompt &optional default hist)
-  "Read a numeric value in the minibuffer, prompting with PROMPT.
+  "Read from the minibuffer and return a numeric value, prompting with PROMPT.
 DEFAULT specifies a default value to return if the user just types RET.
 For historical reasons, the value of DEFAULT is always inserted into
 PROMPT, so it's recommended to use `format' instead of `format-prompt'
index 1188a965f6fff63a9b80b32d802ef6ecb033b3cd..3c76db202c7885363c88367bfc9a052a65ede814 100644 (file)
@@ -92,6 +92,9 @@ PROMPT will be inserted at the start of the buffer, but won't be
 included in the resulting string.  If nil, no prompt will be
 inserted in the buffer.
 
+When the user exits recursive edit, this function returns the
+edited STRING.
+
 Also see `string-edit'."
   (string-edit
    prompt
index b8ed3a35957f430bd957ddff1601a164552fc3c0..619a362d328e5e98ff31b095e4b26cda0e4fe46b 100644 (file)
@@ -8625,7 +8625,8 @@ about coding-system objects.  */)
 
 DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
        Sread_non_nil_coding_system, 1, 1, 0,
-       doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.  */)
+       doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.
+Return the symbol of the coding-system.  */)
   (Lisp_Object prompt)
 {
   Lisp_Object val;
@@ -8641,6 +8642,8 @@ DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
 DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0,
        doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.
 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.
+Return the coding-system's symbol, or nil if both the user input and
+DEFAULT-CODING-SYSTEM are empty or null.
 Ignores case when completing coding systems (all Emacs coding systems
 are lower-case).  */)
   (Lisp_Object prompt, Lisp_Object default_coding_system)
index 1d41a9d5cf4b1b6ab083b8d95ab976ccf054cc5e..6610f82d9271592e05c9b4a274a1013df6679cc2 100644 (file)
@@ -859,7 +859,7 @@ read_filtered_event (bool no_switch_frame, bool ascii_required,
 
 DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0,
        doc: /* Read a character event from the command input (keyboard or macro).
-It is returned as a number.
+Return the character as a number.
 If the event has modifiers, they are resolved and reflected in the
 returned character code if possible (e.g. C-SPC yields 0 and C-a yields 97).
 If some of the modifiers cannot be reflected in the character code, the
@@ -907,7 +907,7 @@ If `inhibit-interaction' is non-nil, this function will signal an
 }
 
 DEFUN ("read-event", Fread_event, Sread_event, 0, 3, 0,
-       doc: /* Read an event object from the input stream.
+       doc: /* Read and return an event object from the input stream.
 
 If you want to read non-character events, consider calling `read-key'
 instead.  `read-key' will decode events via `input-decode-map' that
@@ -943,7 +943,7 @@ If `inhibit-interaction' is non-nil, this function will signal an
 
 DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 3, 0,
        doc: /* Read a character event from the command input (keyboard or macro).
-It is returned as a number.  Non-character events are ignored.
+Return the character as a number.  Non-character events are ignored.
 If the event has modifiers, they are resolved and reflected in the
 returned character code if possible (e.g. C-SPC yields 0 and C-a yields 97).
 If some of the modifiers cannot be reflected in the character code, the
index 026a8f4271e9c7df0c267ac1876ee99f0a4ffd88..3cb7ff47030df3c1da9c7f610a69be903647c62a 100644 (file)
@@ -1292,7 +1292,7 @@ barf_if_interaction_inhibited (void)
 
 DEFUN ("read-from-minibuffer", Fread_from_minibuffer,
        Sread_from_minibuffer, 1, 7, 0,
-       doc: /* Read a string from the minibuffer, prompting with string PROMPT.
+       doc: /* Read and return a string from the minibuffer, prompting with string PROMPT.
 The optional second arg INITIAL-CONTENTS is an obsolete alternative to
   DEFAULT-VALUE.  It normally should be nil in new code, except when
   HIST is a cons.  It is discussed in more detail below.
@@ -1444,7 +1444,7 @@ inherits the current input method and the setting of
 }
 
 DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0,
-       doc: /* Read the name of a command and return as a symbol.
+       doc: /* Read the name of a command and return it as a symbol.
 Prompt with PROMPT.  By default, return DEFAULT-VALUE or its first element
 if it is a list.  If DEFAULT-VALUE is omitted or nil, and the user enters
 null input, return a symbol whose name is an empty string.  */)